<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="javascript" src="/framework/lodop/LodopFuncs.js"></script>
<object  id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
    <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0 style="display: none;"></embed>
</object>
<script>

var LODOP = {

    lodop:'',

    //检查是否安装打印控件
    checkPrint:function(oOBJECT,oEMBED){

        var LODOP = oEMBED;

        try{

            LODOP.SET_LICENSES("上海志承软件有限公司","452725975718688748719056235623","","");

            return LODOP;

        }catch ( err ){

            return false;

        }

    },

    /**
     * 执行打印--配货单
     * @param data      html代码数组 (key为包裹号)
     * @param size      打印尺寸
     * @param fields    显示字段
     * @return package_no   打印成功的包裹号数组
     */
    print : function (data,html_size,fields){

        LODOP.lodop = LODOP.checkPrint( document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM') );

        if( LODOP.lodop == false ){
            E.alert('无法打印，请检查是否已安装打印控件');
            return false;
        }

        //打印成功的包裹号数组
        var package_no = { };

        var returnArr = { };

        //默认html尺寸
        size = {
            top : 0,
            left : 0,
            width : 1350,
            height : 2270
        }

        //如果有传入html尺寸
        if( !$.isEmptyObject(html_size) ){
            size = E.concat(size,html_size);
        }

        LODOP.lodop.PRINT_INIT("打印配货单");

        //设置打印纸张的大小
        LODOP.lodop.SET_PRINT_PAGESIZE(0,size.width,size.height,'');

        //循环打印的内容
        $.each(data, function (k,v){

            LODOP.lodop.ADD_PRINT_HTML(0,0,size.width,"100%", v.print);   //设置打印的html代码及大小

            if( !$.isEmptyObject(fields) && !E.isEmpty(fields.barCode) && v.page == 1 ){
                LODOP.lodop.SET_PRINT_STYLEA(0,"NotOnlyHighPrecision",true);    //开启低精度扫描条码格式
                LODOP.lodop.ADD_PRINT_BARCODE(40,20,230,45,'Code39', v.package_no);           //条码尺寸及格式
            }

            LODOP.lodop.NEWPAGE();          //分页

            package_no[v.package_no] = v.package_no;


        });

        if(LODOP.lodop.PREVIEW()){
            return package_no;
        }else{
            return returnArr;
        }

    },

    //打印批次粗配单
    cupeiPrint:function( html ){

        LODOP.lodop = LODOP.checkPrint( document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM') );

        if( LODOP.lodop == false ){
            E.alert('无法打印，请检查是否已安装打印控件');
            return false;
        }

        LODOP.lodop.PRINT_INIT("打印粗配单");

        //默认html尺寸
        size = {
            top : 0,
            left : 0,
            width : 2100,
            height : 800
        }

        LODOP.lodop.ADD_PRINT_HTM(0,0,size.width,"100%", html);

        if(LODOP.lodop.PREVIEW()){
            return 1;
        }else{
            return 0;
        }

    },

    /**
     * 执行打印--快递单
     * @param params  快递单打印方法返回的data
     * @param flg   0:预览  1:正式
     */
    printExpress : function (params,flg){

        LODOP.lodop = LODOP.checkPrint( document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM') );

        if( LODOP.lodop == false ){
            E.alert('无法打印，请检查是否已安装打印控件');
            return false;
        }

        //打印的包裹
        var package_no = { };
        LODOP.lodop.PRINT_INITA(params['init'][0],params['init'][1],params['init'][2],params['init'][3],'printExpress');
        LODOP.lodop.SET_PRINT_PAGESIZE(0,params['init'][2]+"px",params['init'][3]+"px",'');
        delete params['init'];
        $.each(params ,function(k, v){
            $.each(v , function (key , value){
                LODOP.lodop.ADD_PRINT_TEXTA(value[0],value[1],value[2],value[3],value[4],value[5]);
            });
            LODOP.lodop.NEWPAGE();
            package_no[k] = k;
        });

        if(LODOP.lodop.PREVIEW() > 0){
            return package_no;
        }else{
            return false;
        }
    },

    /**
     * 打印配送单
     *
     * @param data      html代码数组 (key为包裹号)
     */
    sendPrint:function( data ){

        LODOP.lodop = LODOP.checkPrint( document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM') );

        if( LODOP.lodop == false ){
            E.alert('无法打印，请检查是否已安装打印控件');
            return false;
        }

        //打印的包裹
        var package_no = new Array();

        //用于返回的数组
        var returnArr = new Array();

        //默认html尺寸
        size = {
            top : 0,
            left : 0,
            width : 600,
            height : 800
        }

        LODOP.lodop.PRINT_INIT("打印配送单");

        LODOP.lodop.SET_PRINT_PAGESIZE(0,800,620,'');

        //循环打印的内容
        $.each(data, function (k,v){

            LODOP.lodop.ADD_PRINT_HTML(size.top,size.left,size.width,"100%",v);   //设置打印的html代码及大小
            LODOP.lodop.ADD_PRINT_BARCODE(80,5,167,40,'Code39',k);
            LODOP.lodop.SET_PRINT_STYLEA(0,"NotOnlyHighPrecision",true);    //开启低精度扫描条码格式

            LODOP.lodop.NEWPAGE(); //分页

            package_no.push(k);

        });

        //当点击了“打印”才返回包裹号数组，否则返回空数组
        if(LODOP.lodop.PREVIEW() > 0){
            return package_no;
        }else{
            return returnArr;
        }

    },


    /**
     * 打印生产信息
     *
     * @param data      html代码数组
     */
    outPrint:function( data ){

        LODOP.lodop = LODOP.checkPrint( document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM') );

        if( LODOP.lodop == false ){
            E.alert('无法打印，请检查是否已安装打印控件');
            return false;
        }

        //打印的出库单号
        var stock_out_id = new Array();

        //用于返回的数组
        var returnArr = new Array();

        //默认html尺寸
        size = {
            top : 0,
            left : 0,
            width : 2100,
            hegiht : 800
        }

        LODOP.lodop.PRINT_INIT("打印出库单");

        LODOP.lodop.ADD_PRINT_HTML(size.top,size.left,size.width,"100%",data);   //设置打印的html代码及大小

//        //循环打印的内容
//        $.each(data, function (k,v){
//
//            LODOP.lodop.ADD_PRINT_HTML(size.top,size.left,size.width,"100%",v);   //设置打印的html代码及大小
//
//            LODOP.lodop.NEWPAGE(); //分页
//
//            returnArr.push(k);
//
//        });

        //当点击了“打印”才返回出库单号数组，否则返回空数组
        if(LODOP.lodop.PREVIEW() > 0){
            return 1;
        }

    },




    /**
     * 打印配送任务清单(订单打印)
     *
     * @param data      html代码数组
     */
    brandPrints:function( data ){

        LODOP.lodop = LODOP.checkPrint( document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM') );

        if( LODOP.lodop == false ){
            E.alert('无法打印，请检查是否已安装打印控件');
            return false;
        }

        //用于返回的数组
        var returnArr = new Array();

        //默认html尺寸
        size = {
            top : 0,
            left : 0,
            width : 1700,
            hegiht : 2100
        }

        LODOP.lodop.PRINT_INIT("打印配送任务清单");

        LODOP.lodop.ADD_PRINT_HTML(size.top,size.left,size.width,"100%", data);   //设置打印的html代码及大小

        LODOP.lodop.NEWPAGE(); //分页


        //当点击了“打印”才返回出库单号数组，否则返回空数组
        if(LODOP.lodop.PREVIEW() > 0){
            return 1;
        }

    },


    /**
     * 打印商标信息(配送单预览打印)
     *
     * @param data      html代码数组
     */
    brandPrintsView:function( data ){

        LODOP.lodop = LODOP.checkPrint( document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM') );

        if( LODOP.lodop == false ){
            E.alert('无法打印，请检查是否已安装打印控件');
            return false;
        }



        //用于返回的数组
        var returnArr = new Array();

        //默认html尺寸
        size = {
            top : 0,
            left : 0,
            width : 1200,
            hegiht : 2100
        }

        LODOP.lodop.PRINT_INIT("打印QS商标");



        //循环打印的内容
        $.each(data, function (k,v){

            LODOP.lodop.ADD_PRINT_HTML(size.top,size.left,size.width,"100%", v);   //设置打印的html代码及大小
            //LODOP.lodop.ADD_PRINT_BARCODE(18,25,167,40,'Code39', v.bill_code);
            //LODOP.lodop.SET_PRINT_STYLEA(0,"NotOnlyHighPrecision",true);    //开启低精度扫描条码格式
            LODOP.lodop.NEWPAGE(); //分页

        });

        //当点击了“打印”才返回出库单号数组，否则返回空数组
        if(LODOP.lodop.PREVIEW() > 0){
            return 1;
        }

    },


    /**
     * 打印生产单(预览打印)
     *
     * @param data      html代码数组
     */
    productionPrintView:function( data ){

        LODOP.lodop = LODOP.checkPrint( document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM') );

        if( LODOP.lodop == false ){
            E.alert('无法打印，请检查是否已安装打印控件');
            return false;
        }



        //用于返回的数组
        var returnArr = new Array();

        //默认html尺寸
        size = {
            top : 0,
            left : 0,
            width : 2100,
            hegiht : 800
        }

        LODOP.lodop.PRINT_INIT("打印QS商标");



        //循环打印的内容
        $.each(data, function (k,v){

            LODOP.lodop.ADD_PRINT_HTML(size.top,size.left,size.width,"100%", v);   //设置打印的html代码及大小
            LODOP.lodop.NEWPAGE(); //分页

        });

        //当点击了“打印”才返回出库单号数组，否则返回空数组
        if(LODOP.lodop.PREVIEW() > 0){
            return 1;
        }

    },


    /**
     * 打印生产单（直接打印）
     *
     * @param data      html代码数组
     */
    productionPrint:function( data ){

        LODOP.lodop = LODOP.checkPrint( document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM') );

        if( LODOP.lodop == false ){
            E.alert('无法打印，请检查是否已安装打印控件');
            return false;
        }



        //用于返回的数组
        var returnArr = new Array();

        //默认html尺寸
        size = {
            top : 0,
            left : 0,
            width : 2100,
            hegiht : 800
        }

        LODOP.lodop.PRINT_INIT("打印QS商标");



        //循环打印的内容
        $.each(data, function (k,v){

            LODOP.lodop.ADD_PRINT_HTML(size.top,size.left,size.width,"100%", v);   //设置打印的html代码及大小
            LODOP.lodop.NEWPAGE(); //分页

        });

        //当点击了“打印”才返回出库单号数组，否则返回空数组
        if(LODOP.lodop.PRINT() > 0){
            return 1;
        }

    },


    /**
     * 打印网点信息
     */
    branchPrint:function( data ){

        LODOP.lodop = LODOP.checkPrint( document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM') );

        if( LODOP.lodop == false ){
            E.alert('无法打印，请检查是否已安装打印控件');
            return false;
        }

        LODOP.lodop.PRINT_INIT("打印网点信息");

        //默认html尺寸
        size = {
            top : 0,
            left : 0,
            width : 600,
            height : 800
        }

        LODOP.lodop.SET_PRINT_PAGESIZE(0,800,620,'');

        LODOP.lodop.ADD_PRINT_HTML(size.top,size.left,size.width,"100%",data.html);   //设置打印的html代码及大小
        LODOP.lodop.ADD_PRINT_BARCODE(10,100,167,40,'Code39',data.code);
        LODOP.lodop.SET_PRINT_STYLEA(0,"NotOnlyHighPrecision",true);    //开启低精度扫描条码格式

        if(LODOP.lodop.PREVIEW() > 0){
            return data.id;
        }else{
            return false;
        }

    },

    /**
     * 合并两个对象数组-----相同值，后面的会覆盖前面的
     * @param arr1
     * @param arr2
     * @returns { }
     */
    concat: function(arr1, arr2) {
        var newArr = { };
        for (var k1 in arr1){
            newArr[k1] = arr1[k1];
        }
        for (var k2 in arr2){
            newArr[k2] = arr2[k2];
        }
        return newArr;
    }
};

</script>
</head>
<body>
</body>
</html>